/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

%module (docstring="Fulguro Realtime Display Module") flgrrtview

%include ../common/common.i

%inline %{

#include <flgrCoreTypes.h>
#include <flgrCoreErrors.h>
#include <flgrCoreData.h>
#include <flgrRtView.h>

%}


typedef struct {
  %immutable;
  //SDL_Surface *surface;
  //SDL_Color palette[256];
  int size_xfactor;
  int size_yfactor;
  int bps;
  %mutable;
}FLGR_RtView2D;

%extend FLGR_RtView2D {
  ~FLGR_RtView2D() {
    flgr2d_rtview_destroy($self);
  }
};

/*********************** Documentation ***********************/
%feature("autodoc","""
[in] FLGR_Data2D source
[in] Height factor (Integer, default = 1)
[in] Width factor(Integer, default = 1)
[return] FLGR_RtView2D\n
Initialize the display window. Height (size_x) factor allow to specify how many images will be displayed vertically (horizontally) 
""") flgr2d_rtview_create;

%feature("autodoc","""
[in] FLGR_RtView2D
[in] FLGR_Data2D source
[in] Height position (Integer, starting to 0)
[in] Width position (Integer, starting to 0)
[return] FLGR_RET_OK, ...\n
Display an image in the position defined by Height and Width position. If no (Height,Width) are given, default values are (0,0) and the upper left of the window will be used to display the image.
""") flgr2d_rtview_refresh;

%feature("autodoc","""
[in] FLGR_RtView2D
[return] nothing\n
Destruct window
""") flgr2d_rtview_destroy;


/*********************** Functions ***********************/

FLGR_RtView2D *flgr2d_rtview_create(FLGR_Data2D *data, int size_yfactor=1, int size_xfactor=1);
FLGR_Ret flgr2d_rtview_refresh(FLGR_RtView2D *window, FLGR_Data2D *data, int size_ypos=0, int size_xpos=0);
void flgr2d_rtview_destroy(FLGR_RtView2D *screen);



%typemap(in) int* {
  int size = SwigArraySize($input);
  int i;

  if(size<256) goto fail;

  $1 = malloc(sizeof(int)*size);
  for(i=0 ; i<size ; i++) 
    $1[i] = (int) (CInt_FromSwigInt(SwigGetArrayVal($input,i)));

 }

%typemap(freearg) int* {
  free($1);
}

FLGR_Ret flgr2d_rtview_set_palette(FLGR_RtView2D *screen, int *rTable, int *gTable, int *bTable);

%clear int*;

